
#include "TObject.h" 
#include "TString.h"
#include "Config.h"
#include "TH1F.h"
#include "TH2F.h"
#include <iostream>
using namespace std;
class PMTtest: public TObject{
	public:
	PMTtest(); //initialization
	~PMTtest();//release resource
//	void Setpp(int pp_wv,int pp_at,float pp_gb, int pp_pp,int pp_fwhm,float pp_bl,float pp_tc,float pp_peak,float pp_charge );
//	void Setap(int ap_pp,int ap_fwhm,float ap_bl,float ap_tc,float ap_peak,float ap_charge,int ap_index );
//	void SetWave_valid(int valid){wave_valid=valid;}
//	TH1F Getwf1d(){return *hist_wf1d;}
	void Fillwf2d(vector<int> wfwave);
 void Fillwf1d(vector<int> wfwave);
	void Fillptc(float  ptc);
	float Getbaseline(){return Wave_baseline;}
	float Calculatebsl(vector<int> wframe);
	float Getsignalpeak(){return Wave_amplitude;}
	float Getsignal_crosstime(){return Wave_tcross;}
	float Getsignal_risetime(){return Wave_risetime;}
	float Getsignal_falltime(){return Wave_falltime;}
	float Getsignal_FWHM(){return Wave_FWHM;}
	float Getsignal_QDC(){return Wave_QDC;}
  float* Getap_time(){return  Wave_aptime;}
  float* Getap_charge(){return Wave_apcharge;}
	int Getsignal_cnn_tag(){return Wave_cnn_tag;}
	int GetIntLeft(){return Inte_Left;}
	int GetIntRight(){return Inte_Right;}

	float Getsignal_afterpulse(){return Wave_afterpulse;}

// set parameters
	void Setbaseline(float bsl){Wave_baseline=bsl;}
	void Setsignalpeak(float signalpeak){Wave_amplitude=signalpeak;}
	void Setsignal_crosstime(float sig_ct){Wave_tcross=sig_ct;}
	void Setsignal_QDC(float sig_QDC){Wave_QDC=sig_QDC;} 
  void Setaptime(float aptime[20]){for(int i=0;i<20;i++){Wave_aptime[i]=aptime[i];}}
  void Setapcharge(float apcharge[20]){for(int i=0;i<20;i++){Wave_apcharge[i]=apcharge[i];}}
	void  SetIntLeft(int intleft){Inte_Left=intleft;}
	void  SetIntRight(int intright){Inte_Right=intright;}

	void Setsignal_afterpulse(float sig_afterpulse){Wave_afterpulse=sig_afterpulse;}

	TH2F Getwf2d(){return *hist_wf2d;}
  TH1F Getwf1d(){return *hist_wf1d;}
	TH1F Getptc(){return *hist_ptc;}
	private:
/******************test information***************************/
//		TString PMTsn; //the serial number of PMT 
//		TString Test_time; //the test time 
//		bool Wave_valid; //validity of current frame
//		int  DAQ_run;  //daq run number of this test
//		int GCUid;    //the id of GCU
//		int GCU_subid;  //the sub channel of one GCU 
//		int Test_HV;	//the high voltage
//		int Test_drawer;	//drawer number
//		int Total_evt;	//total event number
//		int frame_length;
//		float adc_calibration_factor;
//		float Test_temperature;
//		float Test_DCR;
///******************charge information***************************/
		float Wave_baseline;
		float Wave_amplitude;
		float Wave_tcross;
		float Wave_risetime;
		float Wave_falltime;
		float Wave_QDC; 
		float Wave_FWHM;
    float Wave_aptime[20];
    float Wave_apcharge[20];
		int Wave_cnn_tag;
		int Inte_Left; //trigger/intergration window left
		int Inte_Right; //trigger/intergration window left
   
		float Wave_afterpulse;

//		float Adc_rangefactor;
//		float Wave_charge;
//		int Wave_tpeak;
//		int Impedancea;   //the impedance of ADC
///****************** parameters from SPE spectrum***************************/
//		double Test_mu;   //the mu value= average p.e #
//		double Test_PDE_c;		//the PDE from container
//		double Test_PDE;		//the final PDE with correction of SS.
///****************** other pulses***************************/
//		float PrepulseRatio;
//		float AfterpulseRatio;
//		int SoftDCR;
///****************** CNN***************************/
//		int CNN_tag;	//waveform classification tag by CNN
//		int CNN0pe;
//		int CNN1pe;
//		int CNN2pe;
//		int CNNmpe;  //events with >=3 p.e.
//		float Test_muCNN
///******************2Dhistograms***************************/
//			TH2F *Hist_wave2d;
//			TH2F *Hist_waveacc2d; //accumulated waveforms;
//			TH2F *Hist_wave2daligned; //accumulated waveforms;
///******************1Dhistograms***************************/
//			TH1F *Hist_average_waveform;
//			TH1F *Hist_QDC;  //charge spectrum
//			TH1F *Hist_QDC_conv;  //charge spectrum
//			TH1F *Hist_QDC_CNN;  //charge spectrum by CNN
//			TH1F *Hist_amp;  //amplitude spectrum
//			TH1F *Hist_rt;  //risetime spectrum
//			TH1F *Hist_ft;  //falltime spectrum
//			TH1F *Hist_amplitude;  //signal amplitude spectrum
///******************histogramsCNN***************************/
//			TH1F *cnn
/******************histograms_waveform fitting***************************/
//		float global_baseline;
		TH2F *hist_wf2d; 
		TH1F *hist_ptc; 
    TH1F *hist_wf1d;
     //cross time of pulses at the full frame
//		TH1F *hist_wf1d; // one of the ap waveform
	 ClassDef(PMTtest,1)
};
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class PMTtest+;
